package com.bp.project.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bp.common.annotation.Log;
import com.bp.common.core.controller.BaseController;
import com.bp.common.core.domain.AjaxResult;
import com.bp.common.enums.EnumBusinessType;
import com.bp.project.domain.BizStageContent;
import com.bp.project.service.IBizStageContentService;
import com.bp.common.utils.poi.ExcelUtil;
import com.bp.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 项目工程步骤内容Controller
 * 
 * @author shaominjie
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/project/content")
public class BizStageContentController extends BaseController {
    @Resource
    private IBizStageContentService bizStageContentService;

    /**
     * 查询项目工程步骤内容列表
     */
    @PreAuthorize("@ss.hasPermi('project:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizStageContent bizStageContent) {
        startPage();
        List<BizStageContent> list = bizStageContentService.selectList(bizStageContent);
        return getDataTable(list);
    }

    /**
     * 导出项目工程步骤内容列表
     */
    @PreAuthorize("@ss.hasPermi('project:content:export')")
    @Log(title = "项目工程步骤内容", businessType = EnumBusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizStageContent bizStageContent) {
        List<BizStageContent> list = bizStageContentService.selectList(bizStageContent);
        ExcelUtil<BizStageContent> util = new ExcelUtil<BizStageContent>(BizStageContent.class);
        return util.exportExcel(list, "content");
    }

    /**
     * 获取项目工程步骤内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:content:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(bizStageContentService.selectById(id));
    }

    /**
     * 新增项目工程步骤内容
     */
    @PreAuthorize("@ss.hasPermi('project:content:add')")
    @Log(title = "项目工程步骤内容", businessType = EnumBusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizStageContent bizStageContent)
    {
        return toAjax(bizStageContentService.insert(bizStageContent));
    }

    /**
     * 修改项目工程步骤内容
     */
    @PreAuthorize("@ss.hasPermi('project:content:edit')")
    @Log(title = "项目工程步骤内容", businessType = EnumBusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizStageContent bizStageContent) {
        return toAjax(bizStageContentService.update(bizStageContent));
    }

    /**
     * 删除项目工程步骤内容
     */
    @PreAuthorize("@ss.hasPermi('project:content:remove')")
    @Log(title = "项目工程步骤内容", businessType = EnumBusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bizStageContentService.deleteByIds(ids));
    }
}
